﻿using System;
using SocialShare.BusinessLogicLayer;
using SocialShare.BusinessEntities;
using SocialShare.BLL;
using System.Configuration;
using SocialShare.DAL.Facades;

public partial class Admin_admin_cms : System.Web.UI.Page
{
    private Int32 CmsId
    {
        get
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.QueryString["CmsId"].ToString()))
                {
                    return Convert.ToInt32(Request.QueryString["CmsId"].ToString());
                }
                else
                {
                    return -1;
                }
            }
            catch
            {
                return -1;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    private void LoadData()
    {
        SiteContentFacade cmsFacade = new SiteContentFacade();
        SocailShare_Site_Contents cms = cmsFacade.GetSite_ContentsByCmsId(CmsId);
        lblCmsTitle.Text = cms.CmsTitle;
        hidCKEDitorValue.Value = cms.CmsContent;
    }

    protected void imgSaveBottom_Click(object sender, EventArgs e)
    {
        ConfigReader configReader = new ConfigReader();
        SiteContentFacade cmsFacade = new SiteContentFacade();

        SocailShare_Site_Contents cms = cmsFacade.GetSite_ContentsByCmsId(CmsId);
        //cms.CmsTitle = txtCmsTitle.Text.Trim();
        cms.CmsContent = hidCKEDitorValue.Value;
        cmsFacade.UpdateSite_Contents(cms);

        divMessage.Visible = true;
        divMessage.Attributes.Add("class", "success");
        lblMessage.Text = configReader.ReadConfigurationValue(ConfigurationManager.AppSettings[APP_SETTINGS_NAME.MessageLocation.ToString()], SITE_MESSAGES.SAVE_SUCCESS.ToString());
    }
}